@ECHO OFF
REM  QBFC Project Options Begin
REM  HasVersionInfo: Yes
REM  Companyname: MixSoft Programming
REM  Productname: MixSoft Programming Language Interpreter
REM  Filedescription: MXSPLI Updater
REM  Copyrights: Copyleft MixSoft Programming, d.o.o. 2016 (Licensed via GPLv3)
REM  Trademarks: MXSPLI is a trademark of MixSoft Programming
REM  Originalname: Updater.bat
REM  Comments: See the license at: https://mxspli.codeplex.com/license
REM  Productversion:  1. 0. 5. 0
REM  Fileversion:  1. 0. 5. 0
REM  Internalname: mxspli
REM  Appicon: icon.ico
REM  AdministratorManifest: Yes
REM  Embeddedfile: download.vbs
REM  Embeddedfile: unzip.exe
REM  QBFC Project Options End
ECHO ON
@echo off
:: MXSPLI
:: MixSoft Programming Language Interpreter
:: Version v3
:: Developers: Mihail Mojsoski
if "%MYFILES%"=="" set MYFILES=%cd%
if "%~1"=="--force" set force=1
if not exist prog.bat set version=0
if exist prog.bat call prog.bat --vercheck
cscript //Nologo "%MYFILES%\download.vbs" http://mixsoft.cf/mxspli/update update
if not exist update goto end
for /f %%a in (update) do set %%a
del update
if "%force%"=="1" goto usc
if "%current_version%"=="%vbeta%" goto end
    call :MsgBox "New update found: %current_version%, would you like to update?"  "VBYesNo+VBQuestion" "Update %current_version%"
    if errorlevel 7 (
        echo Don't update.
    ) else if errorlevel 6 (
		call :usc
    )
goto end

:usc
		cscript //Nologo "%MYFILES%\download.vbs" %current_script% update.bat
		call update.bat
		del update.bat
		cscript //Nologo "%MYFILES%\download.vbs" %current_update% update.zip
		call "%MYFILES%\unzip" update.zip
		del update.zip
goto end

:MsgBox prompt type title
    setlocal enableextensions
    set "tempFile=%temp%\%~nx0.%random%%random%%random%vbs.tmp"
    >"%tempFile%" echo(WScript.Quit msgBox("%~1",%~2,"%~3") & cscript //nologo //e:vbscript "%tempFile%"
    set "exitCode=%errorlevel%" & del "%tempFile%" >nul 2>nul
    endlocal & exit /b %exitCode%
:end
